package ws

import (
	"GoServer/message"
	"GoServer/utils/debug"
	"encoding/json"
	"fmt"
)

type LiveInteractiveData struct {
	message.Message

	Data string `json:"data"` /// 直播数据
}

// 需要重写此方法才能完整的msg转byte[]
func (data *LiveInteractiveData) MarshalBinary() ([]byte, error) {
	return json.Marshal(data)
}

func (data *LiveInteractiveData) SendToClient(roomId string) {
	jsonData, err := data.MarshalBinary()
	if err == nil {
		SendMessageToClient(roomId, jsonData)
		debug.Logf(debug.Info, fmt.Sprintf("推送直播互动数据到客户端[%s]", string(jsonData)))
	} else {
		debug.Logf(debug.Info, fmt.Sprintf("未找到连接的房间[%s]", roomId))
	}
}
